<?php

include 'connectBDD.php';

$mail = $_GET['mail'];
if (!empty($mail) && preg_match("#^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-z]{2,4}$#", $mail)) {
    $req = "SELECT mail FROM user WHERE mail='" . $mail . "' ";
    $res = mysql_query($req) or die(mysql_error());
    $nb = mysql_num_rows($res);
    if ($nb == 0) {
        echo '0';
    } else {
        echo '1';
    }
} else {
    echo '2';
}
?>